<?php
session_start();
header('Status: 410');

include_once("priedai/conf.php");
ob_start ();

if (isset($_POST['action']) && $_POST['action'] == 'prisijungimas') {
	$strUsername = htmlspecialchars($_POST['vartotojas']);
	$strPassword = md5($_POST['slaptazodis']);
	$linfo = mysql_fetch_assoc(mysql_query("SELECT id, levelis FROM ".LENTELES_PRIESAGA."users WHERE nick=" . escape($strUsername) ." AND pass='" . $strPassword ."'"));
	if (!empty($linfo)) {
    		$_SESSION['username'] = $strUsername;
    		$_SESSION['password'] = $strPassword;
    		$_SESSION['id'] = $linfo['id'];
      		define("LEVEL", $linfo['levelis']);
      		mysql_query("UPDATE `".LENTELES_PRIESAGA."users` SET `login_data` = NOW( ) WHERE `id` ='" . $linfo['id'] ."' LIMIT 1");
      		unset($linfo);
 	}
  	else {
    	$strError = 'Klaidingi duomenys';
  	}
  	unset($linfo,$strUsername,$strPassword);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Description" content="<?php echo input(strip_tags($conf['Pavadinimas']).' - '.trimlink(strip_tags($conf['Apie']),120)); ?>">
<title><?php echo input(strip_tags($conf['Pavadinimas'])); ?></title>

<link rel="SHORTCUT ICON" href="favicon.ico" /> 
<link href="stilius/<?php echo $conf['Stilius']; ?>/default.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="stiliai/system.css">
<script type="text/javascript" src="javascript/swfobject.js"></script>
<script type="text/javascript" src="javascript/scriptaculous/lib/prototype.js"></script>
<script type="text/javascript" src="javascript/scriptaculous/src/scriptaculous.js"></script>
<script language="javascript" src="javascript/pagrindinis.php" type="text/javascript"></script>

</head>

<body>
<table width="400px" align="center" class="main">
<tr class="center_header"><td>
<?php
klaida("Remontas",$conf['Maintenance']);
?>
</td>
</tr>
<tr>
<td class="center_middle">
<?php
if ($conf['Palaikymas'] == 1 && !defined("LEVEL")) {
				$text = "
					<center>".((isset($strError))?$strError:'')."
			  			<form id=\"user_reg\" name=\"user_reg\" method=\"post\" action=\"\">
							<label for=\"vartotojas\">Vartotojas:</label>
							<br />
							<input name=\"vartotojas\" type=\"text\"  value=\"\" maxlength=\"50\" />
							<br />
							<label for=\"slaptazodis\">Slaptažodis:</label>
							<br />
							<input name=\"slaptazodis\" type=\"password\" value=\"\" maxlength=\"50\" />
							<br />
							<input type=\"submit\" name=\"Submit\" value=\"Prisijungti\" />
							<input type=\"hidden\" name=\"action\" value=\"prisijungimas\" />
						</form>
					</center>";
				lentele("Administratoriams",$text,"Administratoriaus prisijungimas:"); unset($text);
}
elseif (defined('LEVEL') && LEVEL == 1) { echo "<a href='?id,43'>Atsijungti</a>"; }
elseif (defined("LEVEL") && LEVEL == 30) { header('location: index.php'); }
else { header('location: remontas.php'); }
?>
</td></tr>
<tr>
<td class="center_footer">
<?php
copyright($conf['Copyright']);
?>
</td>
</tr>
</table>

</body>
</html>